<?
require_once("../config/dbconn.php");require_once("../config/powercls.php");require_once("../config/pagecls.php");

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	
}
td{
font-size:12px;
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">入库列表</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td align="center" class="left_bt2"><form name="form1" method="post" action="?action=query">
                    <span class="left_txt">分类:
                    <select name="psortid">
                      <option value="">请选择</option>
                      <?
		$sql="select * from {$db_prefix}psort where 1 order by orders asc";
		$result=$db->query($sql);
		while($rs=$db->fetch_array($result)){
			echo "<option value='".$rs['id']."'";
			echo ">".str_repeat("------",$rs['depth']-1).$rs['flname']."</option>";
		}
		$db->free_result($result);
		?>
                    </select>
产品名</span>:<span class="left_txt">
<input name="productname" type="text" id="productname" size="10" />
入库数量:
<input name="rnum1" type="text" id="rnum1" size="5">
-
<input name="rnum2" type="text" id="rnum2" size="5">
<label>
<input type="submit" name="Submit" value="查询">
</label>
</span>
                                                                                          </form>
                  </td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30"><table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" >产品编号</td>
                  <td align="center" bgcolor="#f2f2f2" >产品名</td>
                  <td align="center" bgcolor="#f2f2f2" >分类</td>
                  <td align="center" bgcolor="#f2f2f2" >市场价</td>
                  <td align="center" bgcolor="#f2f2f2" >会员价</td>
                  <td align="center" bgcolor="#f2f2f2" >pv</td>
                  <td align="center" bgcolor="#f2f2f2" >入库数量</td>
                  <td align="center" bgcolor="#f2f2f2" >入库时间</td>
                  <td height="30" align="center" bgcolor="#f2f2f2" >说明</td>
                  </tr>
				  <?
  $query='';
  if ($action=='query'){
  	if ($psortid!=''){
		$pstr='';
		$sqlf="select id,flname from {$db_prefix}psort where find_in_set('$psortid',path)>0 or id='$psortid'";
		$resultf=$db->query($sqlf);
		while($rsf=$db->fetch_array($resultf)){
			if ($pstr!='') $pstr.=',';$pstr.=$rsf['id'];
		}
		$db->free_result($resultf);
		
		if ($pstr!=''){
			$query.=" and find_in_set(a.psortid,'$pstr')>0";
		}
	}	
	if (trim($productname)!='') $query.=" and a.productname like '%".trim($productname)."%'";
	if (trim($rnum1)!='') $query.=" and b.num>='".trim($rnum1)."'";
	if (trim($rnum2)!='') $query.=" and b.num<='".trim($rnum2)."'";
  }
  
  $sql="select count(b.id) as c from {$db_prefix}products a,{$db_prefix}ruku b where a.id=b.proid";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select a.*,b.num as num1,b.rktime,b.content as content1 from {$db_prefix}products a,{$db_prefix}ruku b where a.id=b.proid";
  if ($query!='') $sql.=$query;
  $sql.=" order by b.id desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td align="center"><?=$rs['id']?></td>
                  <td align="center"><a href="product_view.php?id=<?=$rs['id']?>"><?=$rs['productname']?></a></td>
                  <td align="center" ><? if ($rs['psortid']){
				  	$sql1="select flname,path from {$db_prefix}psort where id='".$rs['psortid']."'";
					$rs1=$db->get_one($sql1);
				  	$cpath=$rs1['path'];
					$pathary=explode(',',$cpath);
					foreach($pathary as $k1=>$v1){
						$sqlf="select flname from {$db_prefix}psort where id='$v1'";
						$rsf=$db->get_one($sqlf);
						if ($k1>0) echo "--";
						echo $rsf['flname'];
						
					}
					echo "--".$rs1['flname'];
				  }?></td>
                  <td align="center" ><?=$rs['scprice']?></td>
                  <td align="center" ><?=$rs['price']?></td>
                  <td align="center" ><?=$rs['pv']?></td>
                  <td align="center" ><?=$rs['num1']?></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['rktime'])?></td>
                  <td height="30" align="center" ><?=stripslashes($rs['content1'])?></td>
                  </tr>
				   <?
  }
  $db->free_result($result);
  ?>
              </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页<?=$page->pagesize?>条 第<?=$page->pageno?>/<?=$page->pagenum?>页 共<?=$page->recnum?>条 <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>

</body>
</html>
